package han.chensing.latos.sound;

import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.files.FileHandle;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

public class CirnoSound implements Sound {
    static Random random=new Random();
    int cacheNum;
    File file;
    protected CirnoSound(FileHandle fileHandle,int cacheNum){
        this.cacheNum=cacheNum;
        try {
            byte[] bytes = fileHandle.readBytes();
            file=File.createTempFile("temp"+random.nextLong(),".pcm");
            file.deleteOnExit();
            FileOutputStream fileOutputStream=new FileOutputStream(file);
            fileOutputStream.write(bytes);
            fileOutputStream.close();
            cacheSound(cacheNum,file.getAbsolutePath());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private native void cacheSound(int cacheNum,String filePath);

    private native void playSound(int cacheNum);

    @Override
    public long play() {
        playSound(cacheNum);
        return -1;
    }

    @Override
    public long play(float volume) {
        return 0;
    }

    @Override
    public long play(float volume, float pitch, float pan) {
        return 0;
    }

    @Override
    public long loop() {
        return 0;
    }

    @Override
    public long loop(float volume) {
        return 0;
    }

    @Override
    public long loop(float volume, float pitch, float pan) {
        return 0;
    }

    @Override
    public void stop() {

    }

    @Override
    public void pause() {

    }

    @Override
    public void resume() {

    }

    @Override
    public void dispose() {

    }

    @Override
    public void stop(long soundId) {

    }

    @Override
    public void pause(long soundId) {

    }

    @Override
    public void resume(long soundId) {

    }

    @Override
    public void setLooping(long soundId, boolean looping) {

    }

    @Override
    public void setPitch(long soundId, float pitch) {

    }

    @Override
    public void setVolume(long soundId, float volume) {

    }

    @Override
    public void setPan(long soundId, float pan, float volume) {

    }
}
